package com.iflytek.day12._03_override;

class Person3 {
  private String name;
  private int age;

  public Person3() {
    System.out.println("父类无参");
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }
}

class Student3 extends Person3 {
  private double score;

  public Student3() {
    // super(); // 调用父类无参构造方法,默认就存在，可以不写，必须再第一行
    System.out.println("子类无参");
  }

  public Student3(double score) {
    // super();  // 调用父类无参构造方法,默认就存在，可以不写，必须再第一行
    this.score = score;
    System.out.println("子类有参");
  }

  public double getScore() {
    return score;
  }

  public void setScore(double score) {
    this.score = score;
  }
}

public class Demo03 {
  public static void main(String[] args) {
    // 调用子类有参数构造方法
    Student3 s3 = new Student3(99.9);
    System.out.println(s3.getScore()); // 99.9
    System.out.println(s3.getName()); // 输出 null
    System.out.println(s3.getAge()); // 输出 0
  }
}
